home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 029a / pdsrt321.zip / ISDEV.C < prev    next >
C/C++ Source or Header  |  1991-02-03  |  863b  |  29 lines

  1. /*
  2.  * ISDEVICE - Will invoke Ms-Dos IOCTL function to "get" the attributes of
  3.  * the specified DOS handle.
  4.  *
  5.  * Result := True     If the specified handle is a device. := False    If the
  6.  * specified handle is a file.
  7.  *
  8.  * Caution: A True return only indicates that the handle is assigned to a device
  9.  * driver.  These include the CON, PRN, AUX and any user installed device
  10.  * drivers.
  11.  *
  12.  * A False return indicates that the handle is assigned to a file that may be on
  13.  * a Floppy, Hard Disk or Ram Disk.
  14.  */
  15.  
  16. #include <stdio.h>
  17. #include <dos.h>
  18.  
  19.  int
  20. isdevice (int handle) {
  21.     union REGS      R;
  22.  
  23.     R.x.ax = 0x4400;            /* MS-DOS IOCTL "Get" function */
  24.     R.x.bx = handle;            /* ... Handle for IOCTL "Get"  */
  25.     R.x.dx = 0;
  26.     intdos(&R, &R);                /* ... MS-DOS Entry Interrupt  */
  27.     if ((R.x.dx & 0x80) == 0) return (0);
  28.     else return (1);
  29.     }